package com.share.demo.thread;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.*;

/**
 * created by caifan 2017/11/29
 */
public class ThreadPoolDemo {
    private static final ThreadPoolExecutor executor = new ThreadPoolExecutor(5, 10, 1000, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(5));
    public static void main(String[] args) {
        for (int i=1;i<10;i++) {
            executor.execute(new MyTask(i));
            System.out.println("线程池中线程数目："+executor.getPoolSize()+"，队列中等待执行的任务数目："+
                    executor.getQueue().size()+"，已执行完的任务数目："+executor.getCompletedTaskCount());
        }
        executor.shutdown();
    }

}




